package com.firefly.service.command.ums;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.firefly.dao.dao.ums.po.LogPo;
import com.firefly.dao.dao.ums.service.LogService;
import com.firefly.util.utils.LocalDateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

@Service
public class LogCommand {
    private final LogService logService;
    @Autowired
    public LogCommand(LogService logService){
        this.logService = logService;
    }
    public Boolean clear(){
        QueryWrapper<LogPo> queryWrapper = new QueryWrapper<>();
        LocalDateTime day = LocalDateUtils.minus(LocalDateTime.now(),30, ChronoUnit.DAYS);
        queryWrapper.lt("created_at", day);
        return logService.remove(queryWrapper);
    }
}
